﻿
var selectdate = '1';

$(function () {
    var $input_dhhm = $('#js_input_dhhm');
    $input_dhhm.on('input', function () {
        if ($input_dhhm.val().length > 11) {
            $input_dhhm.val($input_dhhm.val().slice(0, 11));
        }
    });

});


//获取已经预定信息
function GetOrder() {
    var ShenFenZheng = $('#js_input_sfz').val();
    var telephone = $('#js_input_dhhm').val();

   

    if (telephone == '' && ShenFenZheng == '') {
        $.alert("请输入身份证或电话！", "信息不全", function () {
        });
        return;
    }
   

    if (ShenFenZheng != '') {
        if (!checkIdCard(ShenFenZheng)) {
            $.alert("身份证校验失败！", "信息不全", function () {
            });
            return;
        }
    }

    if (telephone != '') {
        if (!checkPhone(telephone)) {
            $.alert("手机号证校验失败！", "信息不全", function () {
            });
            return;
        }
    }

    $.showLoading();
    var tm = setTimeout(function () {
        $.hideLoading();
        $.alert("系统繁忙，请稍后再试！", "超时", function () { });
    }, 20000);

    $.ajax({
        type: "GET",
        url: "http://" + A_Url + "/api/yudingfind",
        //数据，json字符串
        data: { info: 'getorderbyparam', ShenFenZheng: ShenFenZheng, telephone: telephone, selectdate: selectdate},
        success: function (result) {
            $.hideLoading();
            clearTimeout(tm);
            if (result == undefined || result == null ) {
                $.alert("没有预定记录！", "未预定", function () {
                    return;
                });
            } else {
                if (result.length > 0) {
                    var tbstr = '';
                    for (var a = 0; a < result.length; a++) {
                        //tbstr += "<tr onclick=\"openrecord('" + result[a].YuDingRiQi + "','" + result[a].ID + "');\"><td title='时间:'>" + formartDateInt(result[a].YuDingRiQi) + "</td><td title='身份证:'>" + result[a].ShenFenZheng + "</td><td title='电话:'>" + result[a].DianHuan +"</td></tr>";
                        if (result[a].ZhuangTai == 1) continue;

                        if (result[a].YuDingShu != result[a].XiaoShuLiang && result[a].YuDingShu > result[a].XiaoShuLiang) {
                            tbstr += "<tr onclick=\"openrecord('" + result[a].YuDingRiQi + "','" + result[a].ID + "');\"><td title='姓名:'>" + result[a].XingMing + "</td><td title='药店:'>" + result[a].YaoDianMing + "</td><td title='状态：'  class='f-green' >" + '请点击，展示二维码' + "</td></tr>";
                        } else {
                            tbstr += "<tr><td title='姓名:'>" + result[a].XingMing + "</td><td title='药店:'>" + result[a].YaoDianMing + "</td><td title='状态：' class='f-red'>" + '已购买完成，无需点击' + "</td></tr>";
                        }
                    }
                    $('#table_list01').html(tbstr);
                } else {
                    $('#table_list01').html('');
                }
            }
        },
        error: function (e) { }
    });

}


function openrecord(selectdateint, orderid) {
    if (selectdateint != undefined && orderid != undefined)
        window.location.href = "http://" + A_Url + '/Main/weixin/guke_order_QR.html?selectdate=' + selectdateint + '&orderid=' + orderid;
}




